package com.ruoyi.system.controller;

import java.util.List;

import com.ruoyi.argument.CurrentUser;
import com.ruoyi.dto.DataWrapper;
import com.ruoyi.system.domain.Student;
import com.ruoyi.system.service.LessonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.system.domain.Lesson;

/**
 * 课程Controller
 *
 * @author ruoyi
 * @date 2023-03-29
 */
@RestController
@RequestMapping("/lesson")
public class LessonController {
    @Autowired private LessonService lessonService;

    /**
     * 删除课程
     */
    @PostMapping("/list")
    @ResponseBody
    public DataWrapper<List<Lesson>> list() {
        List<Lesson> list = this.lessonService.selectAll();
        return DataWrapper.success(list);
    }

    @PostMapping("/detail")
    @ResponseBody
    public DataWrapper<Lesson> detail(Integer lessonId, @CurrentUser Student student) {
        Lesson lesson = this.lessonService.selectLesson(lessonId,student.getStudentId());
        return DataWrapper.success(lesson);
    }
}
